package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.vo.CustomerTransactionVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CustomerTransaction;
import com.ruoyi.system.service.ICustomerTransactionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户账户流水Controller
 * 
 * @author ruoyi
 * @date 2024-12-16
 */
@RestController
@RequestMapping("/wms/transactionKH")
public class CustomerTransactionController extends BaseController
{
    @Autowired
    private ICustomerTransactionService customerTransactionService;

    /**
     * 查询客户账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('wms:transactionKH:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerTransactionVo customerTransaction)
    {
        startPage();
        List<CustomerTransactionVo> list = customerTransactionService.selectCustomerTransactionList(customerTransaction);
        return getDataTable(list);
    }

    /**
     * 导出客户账户流水列表
     */
//    @PreAuthorize("@ss.hasPermi('wms:transactionKH:export')")
//    @Log(title = "客户账户流水", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, CustomerTransaction customerTransaction)
//    {
//        List<CustomerTransaction> list = customerTransactionService.selectCustomerTransactionList(customerTransaction);
//        ExcelUtil<CustomerTransaction> util = new ExcelUtil<CustomerTransaction>(CustomerTransaction.class);
//        util.exportExcel(response, list, "客户账户流水数据");
//    }

    /**
     * 获取客户账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:transactionKH:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(customerTransactionService.selectCustomerTransactionById(id));
    }

    /**
     * 新增客户账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transactionKH:add')")
    @Log(title = "客户账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerTransaction customerTransaction)
    {
        return toAjax(customerTransactionService.insertCustomerTransaction(customerTransaction));
    }

    /**
     * 修改客户账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transactionKH:edit')")
    @Log(title = "客户账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerTransaction customerTransaction)
    {
        return toAjax(customerTransactionService.updateCustomerTransaction(customerTransaction));
    }

    /**
     * 删除客户账户流水
     */
    @PreAuthorize("@ss.hasPermi('wms:transactionKH:remove')")
    @Log(title = "客户账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerTransactionService.deleteCustomerTransactionByIds(ids));
    }
}
